package hlhj.fhp.supreme.adapters

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.support.v4.view.PagerAdapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.activitys.LoginAty
import kotlinx.android.synthetic.main.nav_item.view.*

/**
 * Created by Administrator on 2018\6\11 0011.
 */
class NavPagerAdp(private val context: Context) :PagerAdapter(){
    override fun isViewFromObject(view: View?, `object`: Any?): Boolean {
        return view==`object`
    }

    override fun instantiateItem(container: ViewGroup?, position: Int): Any {
        val view =LayoutInflater.from(context).inflate(R.layout.nav_item,null)

        when(position){
            0->{
                view.itemImg.setImageResource(R.mipmap.ic_nav1)
                view.btGo.visibility=View.GONE
                view.btGo.setOnClickListener {  }
            }
            1->{
                view.itemImg.setImageResource(R.mipmap.ic_nav2)
                view.btGo.visibility=View.GONE
                view.btGo.setOnClickListener {  }
            }
            2->{
                view.itemImg.setImageResource(R.mipmap.ic_init_bg)
                view.btGo.visibility=View.VISIBLE
                view.btGo.setOnClickListener {
                    val intent = Intent(context, LoginAty::class.java)
                    context.startActivity(intent)
                    val activity = context as Activity
                    activity.finish()
                }
            }

        }
        container?.addView(view)
        return view
    }
    override fun getCount(): Int {
        return  3
    }

    override fun destroyItem(container: ViewGroup?, position: Int, `object`: Any?) {
//        super.destroyItem(container, position, `object`)
    }
}